<?xml version="1.0" encoding="UTF-8"?>
<html>
<title>JVM interpreter in JavaScript</title>
<br>

<script type="text/javascript" src="parser.js"></script>

<input type="file" id="fileinput"/>

<br><br>
<textarea id="parse" name="parse" cols="100" rows="20" > </textarea> 
<textarea id="binary" name="binary" cols="100" rows="20" > </textarea> 

<script type="text/javascript">
	function readSingleFile(evt) {
	//Retrieve the first (and only!) File from the FileList object
		var f = evt.target.files[0]; 
		var contents = null;
		if (f) {
			var r = new FileReader();
            r.readAsBinaryString(f);
			r.onload = function(e) { 
				contents = e.target.result;
				var result = tryParseClassFile(contents);
				if (result != "succeed") {
					alert(result);
					document.getElementById('parse').value = result;
				}
				//document.getElementById('show').value=contents;
			}
			//r.readAsText(f);      
		} else { 
			alert("Failed to load file");
		}
		return contents;
	}
	document.getElementById('fileinput').addEventListener('change', readSingleFile, false);
</script>

</html>